home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / WIN / VB_DB / PROFIT.ZIP / SALESMIX.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-03-19  |  11.5 KB  |  444 lines

  1. VERSION 2.00
  2. Begin Form SalesMix 
  3.    BackColor       =   &H00E0FFFF&
  4.    Caption         =   "Sales Mix File Maintenance"
  5.    Height          =   1875
  6.    Icon            =   SALESMIX.FRX:0000
  7.    Left            =   1290
  8.    LinkMode        =   1  'Source
  9.    LinkTopic       =   "SalesMix"
  10.    MaxButton       =   0   'False
  11.    MDIChild        =   -1  'True
  12.    ScaleHeight     =   1470
  13.    ScaleWidth      =   6225
  14.    Top             =   2130
  15.    Width           =   6345
  16.    Begin CommandButton CmdClose 
  17.       Caption         =   "&Close"
  18.       Height          =   375
  19.       Left            =   5280
  20.       TabIndex        =   10
  21.       Top             =   960
  22.       Width           =   855
  23.    End
  24.    Begin CommandButton CmdCancel 
  25.       Cancel          =   -1  'True
  26.       Caption         =   "Cancel"
  27.       FontBold        =   0   'False
  28.       FontItalic      =   0   'False
  29.       FontName        =   "MS Sans Serif"
  30.       FontSize        =   8.25
  31.       FontStrikethru  =   0   'False
  32.       FontUnderline   =   0   'False
  33.       Height          =   375
  34.       Left            =   4440
  35.       TabIndex        =   9
  36.       Top             =   960
  37.       Width           =   855
  38.    End
  39.    Begin CommandButton CmdDelete 
  40.       Caption         =   "&Delete"
  41.       FontBold        =   0   'False
  42.       FontItalic      =   0   'False
  43.       FontName        =   "MS Sans Serif"
  44.       FontSize        =   8.25
  45.       FontStrikethru  =   0   'False
  46.       FontUnderline   =   0   'False
  47.       Height          =   375
  48.       Left            =   3480
  49.       TabIndex        =   8
  50.       Top             =   960
  51.       Width           =   855
  52.    End
  53.    Begin CommandButton CmdUpdate 
  54.       Caption         =   "&Update"
  55.       FontBold        =   0   'False
  56.       FontItalic      =   0   'False
  57.       FontName        =   "MS Sans Serif"
  58.       FontSize        =   8.25
  59.       FontStrikethru  =   0   'False
  60.       FontUnderline   =   0   'False
  61.       Height          =   375
  62.       Left            =   2640
  63.       TabIndex        =   7
  64.       Top             =   960
  65.       Width           =   855
  66.    End
  67.    Begin CommandButton CmdAdd 
  68.       Caption         =   "&Add"
  69.       FontBold        =   0   'False
  70.       FontItalic      =   0   'False
  71.       FontName        =   "MS Sans Serif"
  72.       FontSize        =   8.25
  73.       FontStrikethru  =   0   'False
  74.       FontUnderline   =   0   'False
  75.       Height          =   375
  76.       Left            =   1800
  77.       TabIndex        =   6
  78.       Top             =   960
  79.       Width           =   855
  80.    End
  81.    Begin CommandButton CmdNext 
  82.       BackColor       =   &H00FFFFFF&
  83.       Caption         =   "&Next"
  84.       FontBold        =   0   'False
  85.       FontItalic      =   0   'False
  86.       FontName        =   "MS Sans Serif"
  87.       FontSize        =   8.25
  88.       FontStrikethru  =   0   'False
  89.       FontUnderline   =   0   'False
  90.       Height          =   375
  91.       Left            =   825
  92.       TabIndex        =   5
  93.       Top             =   960
  94.       Width           =   735
  95.    End
  96.    Begin CommandButton CmdPrevious 
  97.       Caption         =   "&Previous"
  98.       FontBold        =   0   'False
  99.       FontItalic      =   0   'False
  100.       FontName        =   "MS Sans Serif"
  101.       FontSize        =   8.25
  102.       FontStrikethru  =   0   'False
  103.       FontUnderline   =   0   'False
  104.       Height          =   375
  105.       Left            =   120
  106.       TabIndex        =   4
  107.       Top             =   960
  108.       Width           =   735
  109.    End
  110.    Begin TextBox Text3 
  111.       Height          =   375
  112.       Left            =   2160
  113.       TabIndex        =   3
  114.       Top             =   480
  115.       Width           =   1140
  116.    End
  117.    Begin TextBox Text2 
  118.       Height          =   375
  119.       Left            =   2160
  120.       TabIndex        =   1
  121.       Top             =   135
  122.       Width           =   1140
  123.    End
  124.    Begin Label LblDesc 
  125.       Alignment       =   1  'Right Justify
  126.       BackColor       =   &H00E0FFFF&
  127.       Caption         =   "&Servings sold:"
  128.       Height          =   255
  129.       Left            =   120
  130.       TabIndex        =   2
  131.       Top             =   480
  132.       Width           =   1815
  133.    End
  134.    Begin Label LblKey 
  135.       Alignment       =   1  'Right Justify
  136.       BackColor       =   &H00E0FFFF&
  137.       Caption         =   "&Recipe No:"
  138.       Height          =   255
  139.       Left            =   240
  140.       TabIndex        =   0
  141.       Top             =   120
  142.       Width           =   1695
  143.    End
  144.   Dim EntryMode As String * 1
  145.   Dim FieldError As Integer
  146.   Dim DeactivatedKey As String
  147. Sub ClearAllFields ()
  148.   EntryMode = "N"
  149.   Text2.Text = ""
  150.   Text3.Text = ""
  151.   Text2.SetFocus
  152.   SetCmdFlags
  153. End Sub
  154. Sub ClearDataFields ()
  155.   Text3.Text = ""
  156. End Sub
  157. Sub CmdAdd_Click ()
  158.     ErrorCheckFields
  159.     MoveFieldsToRecord
  160.     If Not FieldError Then
  161.     WriteSalesMix
  162.     Select Case SalesMixSt%
  163.       Case 0
  164.         ClearAllFields
  165.       Case 3
  166.         MsgSalesMixNotOpen
  167.       Case 5
  168.         Msg$ = "Sales Mix already on file."
  169.         T1% = MsgBox(Msg$, 0, "Note")
  170.         Text2.SetFocus
  171.       Case Else
  172.         MsgUnknownSalesMixError
  173.     End Select
  174.     End If
  175. End Sub
  176. Sub CmdCancel_Click ()
  177.   If EntryMode = "C" Then
  178.     Text2.Text = SalesMixSaveRec.RecNo
  179.     Text3.Text = RTrim$(LTrim$(Str$(SalesMixSaveRec.ServingsSold)))
  180.     Text3.SetFocus
  181.     Text3.SelStart = Len(Text3.Text)
  182.     EntryMode = "U"
  183.     SetCmdFlags
  184.   Else
  185.     ClearAllFields
  186.   End If
  187. End Sub
  188. Sub CmdClose_Click ()
  189.   Unload SalesMix
  190. End Sub
  191. Sub CmdDelete_Click ()
  192.     Msg$ = "Are you sure?"
  193.     TI% = MsgBox(Msg$, 260, "Delete?")
  194.     If TI% = 6 Then
  195.       DeleteSalesMix
  196.       Select Case SalesMixSt%
  197.     Case 0
  198.       ClearAllFields
  199.     Case 8
  200.       Msg$ = "Record must be found before you can delete."
  201.       Beep
  202.       T1% = MsgBox(Msg$, 0, "Warning!")
  203.     Case 80
  204.       Msg$ = "This record updated since read. Reread and try again."
  205.       Beep
  206.       T1% = MsgBox(Msg$, 0, "Not Deleted!")
  207.     Case Else
  208.       Msg$ = "Sales Mix not deleted.  Status = " + Str$(SalesMixSt%)
  209.       Beep
  210.       T1% = MsgBox(Msg$, 0, "Warning!")
  211.       End Select
  212.     End If
  213. End Sub
  214. Sub CmdNext_Click ()
  215.   NextSalesMix
  216.   Select Case SalesMixSt%
  217.     Case 0
  218.       DisplayDataFields
  219.     Case 3
  220.       MsgSalesMixNotOpen
  221.     Case 8
  222.       FirstSalesMix
  223.       If SalesMixSt% <> 0 Then
  224.     MsgUnknownSalesMixError
  225.       Else
  226.     DisplayDataFields
  227.       End If
  228.     Case 9
  229.       Msg$ = "End of Sales Mix file."
  230.       T1% = MsgBox(Msg$, 0, "Note")
  231.     Case Else
  232.       MsgUnknownSalesMixError
  233.   End Select
  234. End Sub
  235. Sub CmdPrevious_Click ()
  236.   PreviousSalesMix
  237.   Select Case SalesMixSt%
  238.     Case 0
  239.       DisplayDataFields
  240.     Case 3
  241.       MsgSalesMixNotOpen
  242.     Case 8
  243.       FirstSalesMix
  244.       If SalesMixSt% <> 0 Then
  245.     MsgUnknownSalesMixError
  246.       Else
  247.     DisplayDataFields
  248.       End If
  249.     Case 9
  250.       Msg$ = "Beginning of Sales Mix file."
  251.       T1% = MsgBox(Msg$, 0, "Note")
  252.     Case Else
  253.       MsgUnknownSalesMixError
  254.   End Select
  255. End Sub
  256. Sub CmdUpdate_Click ()
  257.     EntryMode = "C"
  258.     SalesMixRec.ServingsSold = Text3.Text
  259.     UpdateSalesMix
  260.     Select Case SalesMixSt%
  261.       Case 0
  262.     EntryMode = "N"
  263.     ClearAllFields
  264.       Case 3
  265.     MsgSalesMixNotOpen
  266.       Case 5
  267.     Msg$ = "Sales Mix duplicate on file."
  268.     T1% = MsgBox(Msg$, 0, "Note")
  269.       Case 8
  270.     Msg$ = "Update only works on found records."
  271.     T1% = MsgBox(Msg$, 0, "Note")
  272.       Case 80
  273.     Msg$ = "This record updated since read. Reread and try again."
  274.     T1% = MsgBox(Msg$, 0, "Warning!")
  275.       Case Else
  276.     MsgUnknownSalesMixError
  277.     End Select
  278. End Sub
  279. Sub DisplayDataFields ()
  280.     SalesMixSaveRec = SalesMixRec
  281.     Text2.Text = SalesMixRec.RecNo
  282.     Text3.Text = LTrim$(RTrim$(Str$(SalesMixRec.ServingsSold)))
  283.     Text3.SetFocus
  284.     EntryMode = "U"
  285.     SetCmdFlags
  286. End Sub
  287. Sub ErrorCheckFields ()
  288.   FieldError = False
  289.   If LTrim$(RTrim$(Text2.Text)) = "" Then
  290.     Msg$ = "Recipe number is required."
  291.     T1% = MsgBox(Msg$, 0, "Note")
  292.     FieldError = True
  293.     Text2.SetFocus
  294.     Exit Sub
  295.   End If
  296.   RecipeRec.RecNo = Text2.Text + String$(6 - Len(Text2.Text), " ")
  297.   ReadRecipe
  298.   If RecipeSt% <> 0 Then
  299.     Msg$ = "Recipe is not on file."
  300.     T1% = MsgBox(Msg$, 0, "Note")
  301.     FieldError = True
  302.     Text2.SetFocus
  303.     Exit Sub
  304.   End If
  305.   If LTrim$(RTrim$(Text3.Text)) = "" Then
  306.     Msg$ = "You must enter servings sold."
  307.     T1% = MsgBox(Msg$, 0, "Note")
  308.     FieldError = True
  309.     Text3.SetFocus
  310.     Exit Sub
  311.   End If
  312. End Sub
  313. Sub Form_Activate ()
  314.    If DeactivatedKey <> "" Then
  315.      SalesMixRec.RecNo = DeactivatedKey
  316.      ReadSalesMix
  317.    End If
  318. End Sub
  319. Sub Form_Deactivate ()
  320.     DeactivatedKey = SalesMixRec.RecNo
  321. End Sub
  322. Sub Form_Load ()
  323.     DeactivatedKey = ""
  324. '    Top = DeliMain.Top + 660
  325. '    Left = DeliMain.Left + 660
  326.     Height = 1875
  327.     Width = 6345
  328.     EntryMode = "N"
  329.     SetCmdFlags
  330. End Sub
  331. Sub MoveFieldsToRecord ()
  332.     SalesMixRec.RecNo = Text2.Text + String$(6 - Len(Text2.Text), " ")
  333.     SalesMixRec.ServingsSold = Val(Text3.Text)
  334. End Sub
  335. Sub SetCmdFlags ()
  336.   Select Case EntryMode
  337.     Case "N"
  338.       CmdPrevious.Enabled = True
  339.       CmdNext.Enabled = True
  340.       CmdCancel.Enabled = False
  341.       CmdAdd.Enabled = True
  342.       CmdUpdate.Enabled = False
  343.       CmdDelete.Enabled = False
  344.     Case "U"
  345.       CmdPrevious.Enabled = True
  346.       CmdNext.Enabled = True
  347.       CmdCancel.Enabled = False
  348.       CmdAdd.Enabled = False
  349.       CmdUpdate.Enabled = True
  350.       CmdDelete.Enabled = True
  351.     Case "C"
  352.       CmdPrevious.Enabled = True
  353.       CmdNext.Enabled = True
  354.       CmdCancel.Enabled = True
  355.       CmdAdd.Enabled = False
  356.       CmdUpdate.Enabled = True
  357.       CmdDelete.Enabled = False
  358.     Case Else
  359.       Msg$ = "Undefined Entry Mode Flag - " + EntryMode + "."
  360.       T1% = MsgBox(Msg$, 0, "Warning!")
  361.   End Select
  362. End Sub
  363. Sub Text2_Change ()
  364.   If EntryMode = "U" Then
  365.     EntryMode = "C"
  366.     SetCmdFlags
  367.   End If
  368. End Sub
  369. Sub Text2_GotFocus ()
  370.   Text2.SelStart = 0
  371.   Text2.SelLength = Len(Text2.Text)
  372. End Sub
  373. Sub Text2_KeyDown (KeyCode As Integer, Shift As Integer)
  374.     If KeyCode = KEY_PAGE_UP Then
  375.     CmdPrevious_Click
  376.     End If
  377.     If KeyCode = KEY_PAGE_DOWN Then
  378.     CmdNext_Click
  379.     End If
  380. End Sub
  381. Sub Text2_KeyPress (KeyAscii As Integer)
  382.   If KeyAscii = 13 Then
  383.     RecipeRec.RecNo = Text2.Text + String$(6 - Len(Text2.Text), " ")
  384.     ReadRecipe
  385.     If RecipeSt% = 0 Then
  386.       KeyAscii = 0
  387.       Text3.SetFocus
  388.     Else
  389.       KeyAscii = 0
  390.       MsgBox "Recipe not on file."
  391.     End If
  392.   Else
  393.     UCStrKP Text2, 6, KeyAscii
  394.   End If
  395. End Sub
  396. Sub Text2_LostFocus ()
  397.   If Text2.Text <> "" Then
  398.     EntryMode = "N"
  399.     SalesMixRec.RecNo = Text2.Text + String$(6 - Len(Text2.Text), " ")
  400.     ReadSalesMix
  401.     Select Case SalesMixSt%
  402.       Case 0
  403.     DisplayDataFields
  404.       Case 3
  405.     MsgSalesMixNotOpen
  406.       Case 4
  407.     ClearDataFields
  408.       Case Else
  409.     MsgUnknownSalesMixError
  410.     End Select
  411.     SetCmdFlags
  412.   End If
  413. End Sub
  414. Sub Text3_Change ()
  415.   If EntryMode = "U" Then
  416.     EntryMode = "C"
  417.     SetCmdFlags
  418.   End If
  419. End Sub
  420. Sub Text3_GotFocus ()
  421.   Text3.SelStart = 0
  422.   Text3.SelLength = Len(Text3.Text)
  423. End Sub
  424. Sub Text3_KeyDown (KeyCode As Integer, Shift As Integer)
  425.     If KeyCode = KEY_PAGE_UP Then
  426.     CmdPrevious_Click
  427.     End If
  428.     If KeyCode = KEY_PAGE_DOWN Then
  429.     CmdNext_Click
  430.     End If
  431. End Sub
  432. Sub Text3_KeyPress (KeyAscii As Integer)
  433.   If KeyAscii = 13 Then
  434.     KeyAscii = 0
  435.     If CmdUpdate.Enabled = True Then
  436.       CmdUpdate.SetFocus
  437.     Else
  438.       CmdAdd.SetFocus
  439.     End If
  440.   Else
  441.     LongKP Text3, 30, KeyAscii
  442.   End If
  443. End Sub
  444.